<html>
	<head>
		<meta charset="utf-8" />
		<title>jquery</title>
		<script src="jquery-1.11.1.js"></script>
		<script src="jquery.validate.js"></script>
	</head>
	<body>
		<form id="verifyForm">
			<fieldset>
				<legend>用户登录</legend>
				<p>
					<label>用户名：</label>
					<input type="text" id="username" name="username" />
				</p>
				<p>
					<label>密码：</label>
					<input type="password" id="pwd" name="pwd" />
				</p>
				<p>
					<input type="submit" value="登录" />
				</p>
			</fieldset>
		</form>
		<script>
			$(document).ready(function(){
				$("#verifyForm").validate({
					rules:{
						username:{
							required:true,
							minlength:2
						},
						pwd:{
							required:true,
							minlength:3
						}
					},
					messages:{
						username:{
							required:"必填",
							minlength:"最小长度为2"
						},
						pwd:{
							required:"必填",
							minlength:"最小长度为3"
						}
					}
				});
			});
		</script>
	</body>
</html>